﻿function Get-TSMServer {    
    <#
        .SYNOPSIS
            Get TSM attached servers
                    
        .DESCRIPTION
            The Get-TSMServer returns attached TSM servers
            
        .EXAMPLE
            Get-TSMServer

        .NOTES
            Contributors:  David Seibel
            Last Revision Date: 09/01/2015



           WORK IN PROGRESS

    #>
    [CmdletBinding()]
    Param()

    $query = Format-TSMQuery -Table "SERVERS"
    $result = Invoke-TSMCommand -Command $query

    $defaultDisplaySet = 'SERVER_NAME','COMMMETH','HL_ADDRESS','LL_ADDRESS','LASTACC_TIME'
    $typeDefinitions = @{
                        "ALLOWREPLACE"       = [bool]
                        "ARCHDELETE"         = [bool]
                        "COMPRESSION"        = [bool]
                        "GRACE_DEL_PERIOD"   = [Int32]
                        "LASTACC_TIME"       = [DateTime]
                        "LASTSESS_COMMWAIT"  = [Double]
                        "LASTSESS_DURATION"  = [Double]
                        "LASTSESS_IDLEWAIT"  = [Double]
                        "LASTSESS_MEDIAWAIT" = [Double] 
                        "LOCKED"             = [bool]
                        "ORIG_DATE"          = [DateTime]
                        "SERVER_INVALID_PWC" = [Int32]
                        "SERVER_PSWET_TIME"  = [DateTime]
                        "SSL"                = [bool]
                        "VALIDATEPROTOCOL"   = [bool]
                        "VV_INVALID_PWC"     = [Int32]
                        "VV_PSWET_TIME"      = [DateTime]
                        "VVNODE_PWD_SET"     = [bool]
                        }

    return Format-TSMData -Data $result -TypeDefinitions $typeDefinitions -DefaultDisplaySet $defaultDisplaySet
}